{% extends 'base.html' %}
{% load rbac %}
{% block menu_style %}
    <style>
        tr.active {
            border-left: orange 3px solid;
        }
    </style>
{% endblock menu_style %}
{% block content %}
    <div class="col-md-8 ">
        <div class="container">
            <div class="row">
                <div class="col-md-2">
                    <div class="panel panel-default">
                        <div class=" panel-heading">一级菜单
                            <a href="{% memory_url request 'rbac:menu_add' %}"
                               class="btn btn-success glyphicon glyphicon-plus pull-right"
                               style="margin-top: -8px;font-size: 8px">新建</a>
                        </div>
                        <table class="table">
                            <thead>
                            <tr>
                                <th>名称</th>
                                <th>选项</th>
                            </tr>
                            </thead>
                            <tbody>
                            {% for menu in menus %}
                                <tr {% if menu.id|safe == current_mid %}
                                    class="active"
                                {% endif %} >
                                    <td>
                                        <a href="?mid={{ menu.id }}">{{ menu.title }}</a>
                                    </td>
                                    <td><a href="{% memory_url request 'rbac:menu_edit' menu.id %}"
                                           class="glyphicon glyphicon-edit"></a>&nbsp;
                                        <a href="{% memory_url request 'rbac:menu_del' menu.id %}" style="color: red"
                                           class="glyphicon glyphicon-minus-sign"></a>
                                    </td>
                                </tr>
                            {% endfor %}

                            </tbody>
                        </table>
                    </div>
                </div>
                <div class="col-md-3">
                    <div class="panel panel-default">
                        <div class=" panel-heading">二级菜单
                            {% if current_mid %}
                                <a href="{% memory_url request 'rbac:second_menu_add' current_mid %}"
                                   class="btn btn-success glyphicon glyphicon-plus pull-right"
                                   style="margin-top: -8px;font-size: 8px">新建</a>
                            {% endif %}
                        </div>
                        <table class="table">
                            <thead>
                            <tr>
                                <th>名称</th>
                                <th>CODE&URL</th>
                                <th>选项</th>
                            </tr>
                            </thead>
                            <tbody>
                            {% for second_menu in second_menus %}
                                <tr {% if second_menu.id|safe == request.GET.sid %}
                                    class="active"
                                {% endif %} >
                                    <td rowspan="2">
                                        <a href="?mid={{ current_mid }}&sid={{ second_menu.id }}">{{ second_menu.title }}</a>
                                    </td>
                                    <td>
                                        <span>{{ second_menu.alias }}</span>
                                    </td>

                                    <td><a href="{% memory_url request 'rbac:second_menu_edit' second_menu.id %}"
                                           class="glyphicon glyphicon-edit"></a>&nbsp;
                                        <a href="{% memory_url request 'rbac:second_menu_del' second_menu.id %}"
                                           style="color: red"
                                           class="glyphicon glyphicon-minus-sign"></a>
                                    </td>
                                </tr>
                                <tr {% if second_menu.id|safe == request.GET.sid %}
                                    class="active"
                                {% endif %} >
                                    <td colspan="2" style="border-top: 0;">
                                        <span>{{ second_menu.url }}</span>
                                    </td>
                                </tr>
                            {% endfor %}

                            </tbody>
                        </table>
                    </div>
                </div>
                <div class="col-md-5">
                    <div class="panel panel-default">
                        <div class=" panel-heading"> 所辖权限
                            {% if current_sid %}
                                <a href="{% memory_url request 'rbac:permission_menu_add' current_sid %}"
                                   class="btn btn-success glyphicon glyphicon-plus pull-right"
                                   style="margin-top: -8px;font-size: 8px">新建</a>
                                <a href="{% url 'rbac:multi_permissions' %}" class=" btn btn-primary pull-right glyphicon glyphicon-share" style="margin-top: -8px;font-size: 8px">批量操作</a>
                            {% endif %}
                        </div>
                        <table class="table">
                            <thead>
                            <tr>
                                <th>名称</th>
                                <th>CODE&URL</th>
                                <th>选项</th>
                            </tr>
                            </thead>
                            <tbody>
                            {% for permission in permissions_list %}
                                <tr>
                                    <td rowspan="2">
                                        <span>{{ permission.title }}</span>
                                    </td>
                                    <td>
                                        <span>{{ permission.alias }}</span>
                                    </td>

                                    <td><a href=""
                                           class="glyphicon glyphicon-edit"></a>&nbsp;
                                        <a href="{% memory_url request 'rbac:permission_menu_del' permission.id %}"
                                           style="color: red"
                                           class="glyphicon glyphicon-minus-sign"></a>
                                    </td>
                                </tr>
                                <tr >
                                    <td colspan="2" style="border-top: 0;">
                                        <span>{{ permission.url }}</span>
                                    </td>
                                </tr>
                            {% endfor %}

                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
{% endblock content %}]